12 void dfs(int u
, int w
, vector
<int> * g
){
17 vector
<int> &vecinos
= g
[u
];
18 for (int i
=0; i
<vecinos
.size(); ++i
){
19 dfs(vecinos
[i
], w
+ 1, g
);
25 while (cin
>> n
&& n
){
27 cin
>> start
, --start
;
31 while (cin
>> p
>> q
&& (p
+q
)){
35 for (int i
=0; i
<n
; ++i
){
36 sort(g
[i
].begin(), g
[i
].end());
39 end
= -1, length
= -1;
42 cout
<< "Case " << C
++ << ": The longest path from " << start
+ 1 << " has length ";
43 cout
<< length
<< ", finishing at " << end
+ 1 << "." << endl
<< endl
;